<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\CourseTeacher;

/**
 * 文章控制器
 */
class Classroom extends AdminBase
{
    
    /**
     * 文章列表
     */
    public function articleList()
    {
        
        $where = $this->logicClassroom->getWhere($this->param);

        $this->assign('list', $this->logicClassroom->getArticleList($where, 'a.*,m.nickname', 'a.create_time desc'));
        $this->assign('teacher', CourseTeacher::all(['status'=>1]));
        return $this->fetch('article_list');
    }
    
    /**
     * 文章添加
     */
    public function articleAdd()
    {
        
        $this->articleCommon();
        
        return $this->fetch('article_edit');
    }
    
    /**
     * 文章编辑
     */
    public function articleEdit()
    {
        
        $this->articleCommon();
        
        $info = $this->logicClassroom->getArticleInfo(['a.id' => $this->param['id']], 'a.*,m.nickname');
        

        
        $this->assign('info', $info);
        
        return $this->fetch('article_edit');
    }
    
    /**
     * 文章添加与编辑通用方法
     */
    public function articleCommon()
    {
        
//      IS_POST && $this->jump($this->logicClassroom->articleEdit($this->param));
        IS_POST && $this->jump($this->logicClassroom->articleEdit($_POST));
        $this->assign('teacher', CourseTeacher::all(['status'=>1]));

    }
    

    
    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('Course', $this->param));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {

        $this->jump($this->logicClassroom->update_info( $this->param));
    }
}
